<template>
    <el-button type="success" size="small" @click="Open">添加流程</el-button>
    <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="index" label="序号" width="100" />
        <el-table-column prop="definName" label="流程名称" width="200" />
        <el-table-column prop="definMsg" label="描述" width="150" />
        <el-table-column fixed="right" label="操作" min-width="150">
            <template #default="scope">
                <el-button link type="primary" size="small" v-if="scope.row.isDel==0" @click="logic(scope.row.id)">设计审批流程</el-button>
            </template>
        </el-table-column>

    </el-table>
    <el-dialog v-model="dialogTableVisible" title="添加流程" width="800">
        <el-form :model="definition" class="demo-form-inline">
            <el-form-item label="流程名称">
                <el-input v-model="definition.definName" clearable />
            </el-form-item>

            <el-form-item label="描述">
                <el-input v-model="definition.definMsg" clearable type="textarea" />
            </el-form-item>
        </el-form>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogTableVisible = false">取消</el-button>
                <el-button type="primary" @click="DefinAdd">确定</el-button>
            </span>
        </template>

    </el-dialog>


</template>

<script lang="ts" setup>
import Maxios from '@/Http/MesHelp'
import { ref, reactive, onMounted } from 'vue'
import moment from 'moment'

import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'

const router = useRouter()
const dialogTableVisible = ref(false)
const definition = reactive({
    "definName": "",
    "audit": "",
    "definMsg": ""
})

const logic = (id: any) => {
    router.push({ path: "/logic", query: { id: id } })

}

const tableData = ref([])

const DefinShow = () => {
    Maxios.post("/api/Audit/GetDefinition"

    ).then(res => {

        tableData.value = res.data.data
    })

}
const DefinAdd = () => {
    Maxios.post("/api/Audit/AddDefinition", definition

    ).then(res => {
        if (res.data.code = 200) {
            ElMessage.success(res.data.message)
            DefinShow()
            dialogTableVisible.value = false

        } else {
            ElMessage.error(res.data.message)
        }

    })

}
const Open = () => {
    dialogTableVisible.value = true


}



onMounted(() => {
    DefinShow()
})

</script>
